package com.caidan.search.config;

import com.caidan.search.interceptor.MyInterceptor;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @项目名 CaiDanSearchSystem
 * @描述 配置类
 * @作者 小菜蛋
 * @时间 2024/12/2 19:53
 */
@Configuration
@Slf4j
public class MvcConfig implements WebMvcConfigurer {
    @Resource
    private MyInterceptor myInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 添加拦截器，并排除登录和注册接口
        log.info("interceptor load successful {}",
                myInterceptor == null
        );
        registry.addInterceptor(myInterceptor)
                .excludePathPatterns("/api/user/login", "/api/user/register")
                .addPathPatterns("/**");
    }
}
